home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / dirwin / data.z / ANIMWIZ.DIR / 00002_Script_Utility routines < prev    next >
Text File  |  1996-03-15  |  4KB  |  130 lines

  1. on Wait nTicks
  2.   set endTime = the ticks + nTicks
  3.   repeat while the ticks < endTime
  4.   end repeat
  5. end Wait
  6.  
  7.  
  8. -- Call this for generic button handling
  9. -- Returns TRUE if the button was pressed
  10. -- or FALSE if the user did not release with the mouse over the button
  11. on PressButton  
  12.   set chButton = the clickOn
  13.   set castNumButtonUp = the castnum of sprite chButton
  14.   
  15.   set btnUpName = the name of cast (castNumButtonUp)
  16.   set nWordsInName = the number of words in btnUpName
  17.   if nWordsInName > 1 then
  18.     if word 2 of btnUpName = "Gray" then
  19.       return FALSE -- button is gray, don't do anything
  20.     end if    
  21.   end if
  22.   
  23.   -- The following assumes the "down button" is one past the "up button" in cast!
  24.   -- For example, there sould be "Book" followed by "Book Down"
  25.   if nWordsInName = 1 then
  26.     set castNumButtonDown = castNumButtonUp + 1  
  27.   else
  28.     set castNumBase = the number of cast(word 1 of btnUpName)
  29.     set castNumButtonDown = castNumBase + 1
  30.   end if
  31.   
  32.   --StartMySound("Click")  
  33.   
  34.   set downFlag = TRUE
  35.   repeat while downFlag
  36.     if rollOver (chButton) then
  37.       set the castnum of sprite chButton = castNumButtonDown
  38.     else
  39.       set the castnum of sprite chButton = castNumButtonUp
  40.     end if
  41.     updateStage
  42.     set downFlag = the stillDown
  43.   end repeat
  44.   --WaitForSound()
  45.   
  46.   set the castnum of sprite chButton = castNumButtonUp
  47.   updateStage
  48.   
  49.   if rollover (chButton) then -- hit the button
  50.     return TRUE
  51.   else  -- did not hit the button
  52.     return FALSE
  53.   end if  
  54. end PressButton
  55.  
  56. -- Call this for generic checkbox button handling
  57. -- Returns TRUE if the user wants to reverse the state of the box
  58. -- or FALSE if not
  59. on PressCheckBox
  60.   set chCheckBox = the clickOn
  61.   set castNumCheckBoxUp = the castnum of sprite chCheckBox
  62.   
  63.   set checkBoxUpName = the name of cast (castNumCheckBoxUp)
  64.   set nWordsInName = the number of words in checkBoxUpName
  65.   if nWordsInName > 1 then
  66.     if word 2 of checkBoxUpName = "Gray" then
  67.       return FALSE -- button is gray, don't do anything
  68.     end if    
  69.   end if
  70.   
  71.   -- The following assumes the "down button" is one past the "up button" in cast!
  72.   set castNumCheckBoxDown = castNumCheckBoxUp + 1  
  73.   
  74.   --StartMySound("Click")    
  75.   set downFlag = TRUE
  76.   repeat while downFlag
  77.     if rollOver (chCheckBox) then
  78.       set the castnum of sprite chCheckBox = castNumCheckBoxDown
  79.     else
  80.       set the castnum of sprite chCheckBox = castNumCheckBoxUp
  81.     end if
  82.     updateStage
  83.     set downFlag = the stillDown
  84.   end repeat
  85.   --WaitForSound()
  86.   
  87.   
  88.   if rollover (chCheckBox) then -- hit the button
  89.     return TRUE
  90.   else  -- did not hit the button
  91.     set the castnum of sprite chCheckBox = castNumCheckBoxUp
  92.     return FALSE
  93.   end if  
  94. end PressCheckBox
  95.  
  96. on IncrMod theCurrentValue, theMaxValue
  97.   if theCurrentValue = theMaxValue then
  98.     return 1
  99.   else
  100.     return (theCurrentValue + 1)
  101.   end if
  102. end IncrMod
  103.  
  104. on DecrMod theCurrentValue, theMaxValue
  105.   if theCurrentValue = 1 then
  106.     return theMaxValue
  107.   else
  108.     return (theCurrentValue - 1)
  109.   end if
  110. end DecrMod
  111.  
  112. on HitWhoH spriteNum, theMax
  113.   set theRealWidth = the right of sprite spriteNum - the left of sprite spriteNum
  114.   set who = (((the mouseH - the left of sprite spriteNum) * theMax) /¼
  115.                  theRealWidth) + 1
  116.   if who <= 1 then
  117.     set who = 1
  118.   end if
  119.   if who > theMax then
  120.     set who = theMax
  121.   end if
  122.   return who
  123. end HitWhoH
  124.  
  125. on Round n
  126.   return integer(n+0.49)
  127. end Round
  128.  
  129.  
  130.